package com.sjl.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sjl.entity.Teachers;
import com.sjl.mapper.TeachersMapper;
import com.sjl.service.TeachersService;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * service实现层
 * @author 宋嘉霖
 *
 */
@Service
public class TeachersServiceImpl extends ServiceImpl<TeachersMapper, Teachers> implements TeachersService {

    @Resource
    private TeachersMapper teachersMapper;

    public IPage<Teachers> selectByPage(Page<Teachers> page, Teachers teachers) {
        // 下一行表示不进行 count sql 优化，解决 MP 无法自动优化 SQL 问题，这时候你需要自己查询 count 部分
        // page.setOptimizeCountSql(false);
        // 当 total 为小于 0 或者设置 setSearchCount(false) 分页插件不会进行 count 查询
        // 要点!! 分页返回的对象与传入的page是同一个对象
        // 可以不注入Mapper，而使用this.baseMapper
        return teachersMapper.selectByPage(page, teachers);
    }

}
